package com.jt.resource.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author 金帮嘉诚 @date 2021-08-18 星期三 20:48
 */
@RestController
@RequestMapping("/demo")
public class DemoController {
    @Autowired
    private RestTemplate loadBalancerRestTemplate;

    @GetMapping("/demo/echo0/{msg}")
    public String echo0(@PathVariable String msg) {
        String serviceId = "sca-providerre";
        String url = String.format("http://%s/provider/echo/%s", serviceId, msg);
        return loadBalancerRestTemplate.getForObject(url, String.class);
    }
}
